package com.newjiabo.ski.service.impl;

import java.util.List;

import com.newjiabo.common.core.domain.entity.SkiMember;
import com.newjiabo.common.utils.DateUtils;
import com.newjiabo.common.utils.SnowFlake;
import com.newjiabo.common.utils.StringUtils;
import com.newjiabo.ski.mapper.SkiMemberMapper;
import com.newjiabo.ski.service.ISkiMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 会员Service业务层处理
 *
 * @author ruoyi
 * @date 2023-09-25
 */
@Service
public class SkiMemberServiceImpl implements ISkiMemberService {
    @Resource
    private SkiMemberMapper skiMemberMapper;

    /**
     * 查询会员
     *
     * @param id 会员主键
     * @return 会员
     */
    @Override
    public SkiMember selectSkiMemberById(String id) {
        return skiMemberMapper.selectSkiMemberById(id);
    }

    /**
     * 查询会员列表
     *
     * @param skiMember 会员
     * @return 会员
     */
    @Override
    public List<SkiMember> selectSkiMemberList(SkiMember skiMember) {
        return skiMemberMapper.selectSkiMemberList(skiMember);
    }

    /**
     * 新增会员
     *
     * @param skiMember 会员
     * @return 结果
     */
    @Override
    public int insertSkiMember(SkiMember skiMember) {
        if(StringUtils.isEmpty(skiMember.getId())){
            skiMember.setId(SnowFlake.getIdStr());
        }
        skiMember.setDelFlag(false);
        skiMember.setCreateTime(DateUtils.getNowDate());
        return skiMemberMapper.insertSkiMember(skiMember);
    }

    /**
     * 修改会员
     *
     * @param skiMember 会员
     * @return 结果
     */
    @Override
    public int updateSkiMember(SkiMember skiMember) {
        skiMember.setUpdateTime(DateUtils.getNowDate());
        return skiMemberMapper.updateSkiMember(skiMember);
    }

    /**
     * 批量删除会员
     *
     * @param ids 需要删除的会员主键
     * @return 结果
     */
    @Override
    public int deleteSkiMemberByIds(String[] ids) {
        return skiMemberMapper.deleteSkiMemberByIds(ids);
    }

    /**
     * 删除会员信息
     *
     * @param id 会员主键
     * @return 结果
     */
    @Override
    public int deleteSkiMemberById(String id) {
        return skiMemberMapper.deleteSkiMemberById(id);
    }

    @Override
    public int resetCameraman(String id) {
        return skiMemberMapper.resetCameraman(id);
    }

    @Override
    public int resetCameramanByIds(String[] id) {
        return skiMemberMapper.resetCameramanByIds(id);
    }
}
